<?php
include "inc/mysql.inc.php";
include 'inc/config.inc.php';

?>
<?php  include 'include/header.php' ?>
			<div id="content" class="span10">
			
			
			<ul class="breadcrumb">
				<li>
					<i class="icon-home"></i>
					<a href="index.php">Home</a>
					<i class="icon-angle-right"></i> 
				</li>
				<li>
					<i class="icon-edit"></i>
					<a href="#">学生缺寝记录</a>
				</li>
			</ul>


                <form action="form.php" method="post">
                	<!-- ID号 <input type="text" name="id" " > -->
                    学号：<input type="text" name="sdnumber" " >
                    日期：<input type="text" name="data" " >
                    <input type="submit" name="sub" value="添加缺寝记录"><br>
                    
                </form>

<form action="form.php" method="post">
	请输入您要查询缺勤的学号：<input type="text" name="number" " >
<input type="submit" name="sub2" value="查询">

</form>
                   
                     <!-- <table width="500" border="2"  >
                        <tr>
                            <th>日期</th>
                           
                            
                        </tr> -->



                  <!-- <?php
              //$link10 = connect();
              //$query10="select * from 8lack_of_sleep where sdnumber={$_POST['number']}";   
              //$result10=execute($link10,$query10);
                  //  while($rs2=mysqli_fetch_assoc($result10))
                    {
                        ?> -->
                       <!--  <tr>
                          
                            <td align="center"><?php echo $rs2['data'] ?></td>        </tr>

                        <?php } ?>  

                    </table>
	 -->
   

	
	<!-- start: JavaScript-->

		<script src="js/jquery-1.9.1.min.js"></script>
	<script src="js/jquery-migrate-1.0.0.min.js"></script>
	
		<script src="js/jquery-ui-1.10.0.custom.min.js"></script>
	
		<script src="js/jquery.ui.touch-punch.js"></script>
	
		<script src="js/modernizr.js"></script>
	
		<script src="js/bootstrap.min.js"></script>
	
		<script src="js/jquery.cookie.js"></script>
	
		<script src='js/fullcalendar.min.js'></script>
	
		<script src='js/jquery.dataTables.min.js'></script>

		<script src="js/excanvas.js"></script>
	<script src="js/jquery.flot.js"></script>
	<script src="js/jquery.flot.pie.js"></script>
	<script src="js/jquery.flot.stack.js"></script>
	<script src="js/jquery.flot.resize.min.js"></script>
	
		<script src="js/jquery.chosen.min.js"></script>
	
		<script src="js/jquery.uniform.min.js"></script>
		
		<script src="js/jquery.cleditor.min.js"></script>
	
		<script src="js/jquery.noty.js"></script>
	
		<script src="js/jquery.elfinder.min.js"></script>
	
		<script src="js/jquery.raty.min.js"></script>
	
		<script src="js/jquery.iphone.toggle.js"></script>
	
		<script src="js/jquery.uploadify-3.1.min.js"></script>
	
		<script src="js/jquery.gritter.min.js"></script>
	
		<script src="js/jquery.imagesloaded.js"></script>
	
		<script src="js/jquery.masonry.min.js"></script>
	
		<script src="js/jquery.knob.modified.js"></script>
	
		<script src="js/jquery.sparkline.min.js"></script>
	
		<script src="js/counter.js"></script>
	
		<script src="js/retina.js"></script>

		<script src="js/custom.js"></script>
	<!-- end: JavaScript-->
               
                <?php
               
                 if(!empty($_POST['sub'])) {
                    if (empty($_POST['sdnumber']) || empty($_POST['data']))
                        echo "请将缺寝记录填写完整";
                    else { 
                    	$link2 = connect(); 
                       	$num = $_POST['sdnumber'];
                        $data = $_POST['data'];
                        $query2 = "insert into 8lack_of_sleep(sdnumber,data) values(
                        '$num','$data')";       
                        $result=execute($link2,$query2);
                         echo '<script type="text/javascript">alert("添加成功")</script>';
                   }     
                 }
                ?>

                 <?php
                 if (!empty($_POST['sub2'])){
                 $link = connect();
               $query9="select count(*) from 8lack_of_sleep where sdnumber={$_POST['number']}";
               $result9=execute($link,$query9);
                $count2=$result9->fetch_array()[0]; 
            }
                 ?>

                <table width="500" border="2"  >
                        <tr>
                            <th>日期</th>
                           
                            
                        </tr>
                 <?php
               if (!empty($_POST['sub2'])){
              $link10 = connect();
              $query10="select * from 8lack_of_sleep where sdnumber={$_POST['number']}";
              $result10=execute($link10,$query10);
                   while($rs2=mysqli_fetch_assoc($result10))
                    {
                        ?>
                       <tr>
                          
                            <td align="center"><?php echo $rs2['data'] ?></td>        </tr>

                        <?php }} ?>  

                    </table>


<table width="500" border="2" >
                        <tr>
                            <th>缺勤次数</th>
     
                        </tr>
            
                  <tr>            
                            <td align="center"><?php echo $count2 ?></td>
                        </tr>

    </table> 

	
</body>
</html>